package com.ws.mapper;

import com.ws.domain.Cart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartsDao {

    //根据用户id查询购物车的购物数量
    @Select("select ifnull(sum(amount), 0) from carts where user_id = #{userId}")
    public int selectSumAmountByUserId(int userId);

    //根据用户ID查询该用户购物车订单信息
    @Select("select * from carts where user_id = #{userId}")
    List<Cart> selectListByUserId(@Param("userId") int userId);

}
